package com.hsc.yalebao.base;

import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.DownloadListener;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;
import com.hsc.yalebao.tabChongZhi.PayResultActivity;
import com.hsc.yalebao.tabMine.ChargeRecordListActivity;
import com.hsc.yalebao.tools.SystemHelper;
import com.hsc.yalebao.weight.LogUtils;
import com.hsc.yalebao.weight.MyLoadingDialog;
import java.io.File;
import java.io.PrintStream;
import java.net.URISyntaxException;

public class MainWebActivity extends BaseActivity
{
  public static String COOKIE_STRING = null;
  private String TAG = "-MainWebActivity-";
  String address = "";
  private String bussId = "";
  View contentView;
  Context context;
  private String cookieKeys = "";
  MyLoadingDialog dialog;
  Handler handler1 = new Handler()
  {
    public void handleMessage(Message paramAnonymousMessage)
    {
      if (!Thread.currentThread().isInterrupted())
        switch (paramAnonymousMessage.what)
        {
        case 0:
        }
      super.handleMessage(paramAnonymousMessage);
    }
  };
  boolean isclick = false;
  private String memberId = "";
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      default:
        return;
      case 2131099699:
      }
      if ("银联支付".equals(MainWebActivity.this.title))
        MainWebActivity.this.startActivity(new Intent(MainWebActivity.this, ChargeRecordListActivity.class));
      CustomApplication.app.finishActivity(MainWebActivity.this);
    }
  };
  private String param = "";
  String payNo = "";
  private MyReceiver receiverNet = null;
  String title = "";
  private String type = "";
  private View view_title;
  WebView wv;

  private void closeWindowSoftInput()
  {
    InputMethodManager localInputMethodManager = (InputMethodManager)getApplicationContext().getSystemService("input_method");
    boolean bool = localInputMethodManager.isActive();
    LogUtils.d("-MianWebActivity-", "isSoftActive：" + bool);
    if (bool)
    {
      localInputMethodManager.hideSoftInputFromWindow(this.wv.getApplicationWindowToken(), 0);
      LogUtils.d(this.TAG, "强制隐藏键盘");
    }
  }

  private void loadUrlWithNetCheck()
  {
    if ((SystemHelper.isConnected(this)) && (SystemHelper.getNetworkType(this) != -1))
    {
      CustomApplication.app.isNetConnect = true;
      if ((this.address != null) && (!"".equals(this.address)))
      {
        this.wv.loadUrl(this.address);
        LogUtils.d(this.TAG, "address：" + this.address);
        showLoadingDialog();
      }
      return;
    }
    CustomApplication.app.isNetConnect = false;
  }

  private void registerNetReceiver()
  {
    this.receiverNet = new MyReceiver();
    IntentFilter localIntentFilter = new IntentFilter();
    localIntentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
    localIntentFilter.setPriority(1000);
    registerReceiver(this.receiverNet, localIntentFilter);
    System.out.println("主页--【网络监听】广播已经注册");
  }

  private void removeCookie(Context paramContext)
  {
    CookieSyncManager.createInstance(paramContext);
    CookieManager.getInstance().removeAllCookie();
    CookieSyncManager.getInstance().sync();
  }

  public static void synCookies(Context paramContext, String paramString1, String paramString2)
  {
    CookieSyncManager.createInstance(paramContext);
    CookieManager localCookieManager = CookieManager.getInstance();
    localCookieManager.setAcceptCookie(true);
    localCookieManager.removeSessionCookie();
    localCookieManager.setCookie(paramString1, paramString2);
    CookieSyncManager.getInstance().sync();
  }

  @SuppressLint({"NewApi", "JavascriptInterface"})
  protected void initWebView()
  {
    setTitle(8, 0, 2130837809, this.title, 8, 8, 0);
    this.wv = ((WebView)findViewById(2131099912));
    this.wv.setVisibility(0);
    this.wv.setDownloadListener(new MyWebViewDownLoadListener(null));
    WebSettings localWebSettings = this.wv.getSettings();
    localWebSettings.setDomStorageEnabled(true);
    localWebSettings.setAppCachePath(getApplicationContext().getDir("cache", 0).getPath());
    localWebSettings.setAllowFileAccess(true);
    localWebSettings.setAppCacheEnabled(true);
    localWebSettings.setCacheMode(-1);
    localWebSettings.setJavaScriptEnabled(true);
    this.wv.setLayerType(1, null);
    if (Build.VERSION.SDK_INT >= 16)
      localWebSettings.setAllowUniversalAccessFromFileURLs(true);
    this.wv.setWebViewClient(new webViewClient());
    this.wv.setWebChromeClient(new MyWebChromeClient());
    loadUrlWithNetCheck();
  }

  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    super.onActivityResult(paramInt1, paramInt2, paramIntent);
    switch (paramInt1)
    {
    default:
      return;
    case 0:
    }
    Intent localIntent = new Intent(this, PayResultActivity.class);
    localIntent.putExtra("payNo", this.payNo);
    startActivity(localIntent);
    CustomApplication.app.finishActivity(this);
  }

  public void onBackPressed()
  {
    if (this.wv.canGoBack())
    {
      this.wv.goBack();
      return;
    }
    finish();
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.context = this;
    CustomApplication.app.addActivity(this);
    this.contentView = LayoutInflater.from(this.context).inflate(2130903068, null);
    setContentView(this.contentView);
    this.address = getIntent().getStringExtra("url");
    this.title = getIntent().getStringExtra("title");
    this.payNo = getIntent().getStringExtra("payNo");
    this.type = getIntent().getStringExtra("type");
    if ((this.type != null) && (this.type.contains("tip")))
      this.param = getIntent().getStringExtra("param");
    if ((this.address != null) && (this.address.length() > 0))
      initWebView();
    while (true)
    {
      CustomApplication.app.addActivity(this);
      registerNetReceiver();
      return;
      finish();
    }
  }

  protected void onDestroy()
  {
    super.onDestroy();
    if (this.receiverNet != null)
    {
      unregisterReceiver(this.receiverNet);
      return;
    }
    LogUtils.e(this.TAG, "onDestroy(),网络监听注销失败");
  }

  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    if (paramInt == 4)
    {
      if ("银联支付".equals(this.title))
        startActivity(new Intent(this, ChargeRecordListActivity.class));
      CustomApplication.app.finishActivity(this);
    }
    return true;
  }

  protected void onResume()
  {
    super.onResume();
  }

  public void setTitle(int paramInt1, int paramInt2, int paramInt3, String paramString, int paramInt4, int paramInt5, int paramInt6)
  {
    View localView = findViewById(2131099716);
    ((TextView)localView.findViewById(2131099701)).setText(paramString);
    ((TextView)localView.findViewById(2131099700)).setVisibility(paramInt1);
    ImageView localImageView1 = (ImageView)localView.findViewById(2131099699);
    localImageView1.setVisibility(paramInt2);
    localImageView1.setOnClickListener(this.onClickListener);
    localImageView1.setImageResource(paramInt3);
    TextView localTextView = (TextView)localView.findViewById(2131099702);
    localTextView.setVisibility(paramInt4);
    localTextView.setOnClickListener(this.onClickListener);
    ImageView localImageView2 = (ImageView)localView.findViewById(2131099704);
    localImageView2.setVisibility(paramInt5);
    localImageView2.setImageResource(paramInt6);
  }

  public class MyReceiver extends BroadcastReceiver
  {
    public MyReceiver()
    {
    }

    public void onReceive(Context paramContext, Intent paramIntent)
    {
      if (paramIntent.getAction().equals("android.net.conn.CONNECTIVITY_CHANGE"))
        MainWebActivity.this.loadUrlWithNetCheck();
    }
  }

  class MyWebChromeClient extends WebChromeClient
  {
    MyWebChromeClient()
    {
    }

    public boolean onJsAlert(WebView paramWebView, String paramString1, String paramString2, JsResult paramJsResult)
    {
      return super.onJsAlert(paramWebView, paramString1, paramString2, paramJsResult);
    }

    public boolean onJsConfirm(WebView paramWebView, String paramString1, String paramString2, JsResult paramJsResult)
    {
      LogUtils.d(MainWebActivity.this.TAG, "onJsConfirm-url:" + paramString1);
      return super.onJsConfirm(paramWebView, paramString1, paramString2, paramJsResult);
    }

    public void onProgressChanged(WebView paramWebView, int paramInt)
    {
      super.onProgressChanged(paramWebView, paramInt);
      if (paramInt == 100)
        MainWebActivity.this.dismissLoadingDialog();
    }
  }

  private class MyWebViewDownLoadListener
    implements DownloadListener
  {
    private MyWebViewDownLoadListener()
    {
    }

    public void onDownloadStart(String paramString1, String paramString2, String paramString3, String paramString4, long paramLong)
    {
      Intent localIntent = new Intent("android.intent.action.VIEW", Uri.parse(paramString1));
      MainWebActivity.this.startActivity(localIntent);
    }
  }

  class webViewClient extends WebViewClient
  {
    webViewClient()
    {
    }

    @SuppressLint({"NewApi"})
    public boolean shouldOverrideUrlLoading(WebView paramWebView, String paramString)
    {
      LogUtils.d(MainWebActivity.this.TAG, "webViewClient-url:" + paramString);
      if ((!"".equals(paramString)) && ((paramString.contains("success")) || (paramString.contains("fail"))))
      {
        MainWebActivity.this.startActivity(new Intent(MainWebActivity.this, ChargeRecordListActivity.class));
        CustomApplication.app.finishActivity(MainWebActivity.this);
      }
      if (paramString.startsWith("tel:"))
      {
        Intent localIntent1 = new Intent("android.intent.action.CALL", Uri.parse(paramString));
        MainWebActivity.this.startActivity(localIntent1);
      }
      if (paramString.startsWith("intent://"))
        try
        {
          Intent localIntent2 = Intent.parseUri(paramString, 1);
          localIntent2.addCategory("android.intent.category.BROWSABLE");
          localIntent2.setComponent(null);
          localIntent2.setSelector(null);
          MainWebActivity.this.startActivityForResult(localIntent2, 0);
          return true;
        }
        catch (URISyntaxException localURISyntaxException)
        {
          localURISyntaxException.printStackTrace();
          return true;
        }
      MainWebActivity.this.wv.loadUrl(paramString);
      return true;
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.base.MainWebActivity
 * JD-Core Version:    0.6.2
 */